package com.exam.service.impl;

import com.exam.mapper.StudentMapper;
import com.exam.po.ExamManage;
import com.exam.po.Student;
import com.exam.service.StudentMannagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhanghui
 * @ClassName StudentMannagerServiceImpl
 * @Description TODO
 * @Date 2021/1/12 11:43
 * @Version 1.0
 **/
@Service
public class StudentMannagerServiceImpl implements StudentMannagerService {
    @Autowired
    private StudentMapper studentMapper;
    /**
     * @Author zhanghui
     * @Description 添加用户
     * @Date 2021/1/12 11:46
     * @Param [student]
     * @return int
     **/
    @Override
    public int addStudent(Student student) {
        return studentMapper.insertSelective(student);
    }

    @Override
    public int deleteStudent(Integer studentid) {
        return studentMapper.deleteByPrimaryKey(studentid);
    }

    @Override
    public int updateStudent(Student student) {
        return studentMapper.updateByPrimaryKeySelective(student);
    }

    @Override
    public List<Student> findStudentByPage(Integer page, Integer size) {
        return studentMapper.selectStudentsByPage((page-1)*size,size);
    }
    /**
     * @Author zhanghui
     * @Description 查询学生考试试卷
     * @Date 2021/1/13 19:26
     * @Param [teacherId, page, size]
     * @return java.util.List<com.exam.po.ExamManage>
     **/
    @Override
    public List<ExamManage> findStudentExam(Integer teacherId, Integer page, Integer size) {
        return studentMapper.selectStudentsExam(teacherId,(page-1)*size,size);
    }
    /**
     * @Author zhanghui
     * @Description 查询学生考试试卷总记录数
     * @Date 2021/1/13 19:26
     * @Param
     * @return
     **/
    @Override
    public Integer findStudentExamCount(Integer teacherId) {
        return studentMapper.findCountStudentExam(teacherId);
    }

    @Override
    public Integer findStudentCounts() {
        return studentMapper.findCountStudens();
    }
}
